<template>
   <ul>
       <li v-for="(item, i) in colors" :key="i" :style="
        {
            background: item
        }
       " :class="current === i ? 'active' : ''" @click="selectColor(item, i)"></li>
   </ul>
</template>

<script>
export default {
  name: '',
  props: ['col'],
  data() { 
    return {
        colors: ['red', 'blue', 'black', 'pink', 'yellow'],
        current: -1
    }
  },
  created() {

  },
  methods:{
      selectColor(color, i) {
        this.$emit('send:color', color)
        this.current = i
      }
  },

  watch: {
      col(to) {
          if(!this.col) {
              this.current = -1
          } else {
              this.colors.forEach((item, i) => {
                  if(item === to) {
                      this.current = i
                  }
              })
          }
      }
  }
 }
</script>

<style scoped lang="scss">
ul{
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 0;
    li{
        width: 60px;
        height: 60px;
        border-radius: 60px;
    }
    .active{
        border: 2px solid purple;
    }
}
</style>